/**
 *  Project: CloudstickUtils 
 *  kr.cloudstick.util.xml-NamespaceContextResolver.java
 * 	
 *	Copyright 2013 Cloudstick (www.cloudstick.kr)
 *
 *	Written by htkim
 *		2013. 3. 25. first written.
 *
 *	Note:	
 */
package kr.cloudstick.util.xml;

import java.util.Iterator;

import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;

import org.w3c.dom.Document;

public final class CSNamespaceContextResolver implements NamespaceContext{
	
	final private Document doc; // NOPMD by cloudstick on 13. 3. 28 5:17
	
	public CSNamespaceContextResolver(final Document doc) {
		this.doc = doc;
	}

	@Override
	public String getNamespaceURI(final String prefix) {
		if ( prefix.equals(XMLConstants.DEFAULT_NS_PREFIX) ) {
			return doc.lookupNamespaceURI(null);
		}
		return doc.lookupNamespaceURI(prefix);
	}

	@Override
	public String getPrefix(final String namespaceURI) {
		// TODO Auto-generated method stub
		return doc.lookupPrefix(namespaceURI);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public Iterator getPrefixes(final String namespaceURI) {
		// TODO Auto-generated method stub
		return null;
	}
}
